package com.kusen.village.raise.util;

import java.util.Calendar;
import java.util.Random;

/**
 * @description: 字符串工具类
 * @author: ghl
 * @create: 2021-10-13 15:32
 **/
public class StringUtil {

    /**
     * 获取申请时按照规则自动生成
     *
     * @param head
     * @return
     */
    public static synchronized String serialNumber(String head) {
        String result = head + getTimeInMillis() + getRandom();
        return result;
    }

    /**
     * 获取当前时间的时间戳
     *
     * @return
     */
    public static String getTimeInMillis() {
        long timeInMillis = Calendar.getInstance().getTimeInMillis();
        return timeInMillis + "";
    }

    /**
     * 获取位数为5位的随机数
     *
     * @return
     */
    public static String getRandom() {
        Random random = new Random();
        int nextInt = random.nextInt(90000);
        nextInt = nextInt + 10000;
        String str = nextInt + "";
        return str;
    }
}
